using AutoMapper;
using Joy.Erp.BasicArchives.Core;

namespace Joy.Erp.BasicArchives.Procurements
{
    public class PurchaseRequisitionAutoMapperProfile : Profile
    {
        public PurchaseRequisitionAutoMapperProfile()
        {
            CreateMap<PurchaseRequisition, PurchaseRequisitionDto>().MapExtraProperties().ReverseMap();
            CreateMap<PurchaseRequisition, PurchaseRequisitionDocumentDto>().MapExtraProperties().ReverseMap();
            CreateMap<PurchaseRequisition, PurchaseRequisitionCreateDto>().MapExtraProperties().ReverseMap();
            CreateMap<PurchaseRequisition, PurchaseRequisitionUpdateDto>()
                .MapExtraProperties()
                .ForMember(dest => dest.Children, opt => opt.Ignore());
            CreateMap<PurchaseRequisitionUpdateDto, PurchaseRequisition>()
                .MapExtraProperties()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.OrderType, opt => opt.Ignore())
                .ForMember(dest => dest.Supplier, opt => opt.Ignore())
                .ForMember(dest => dest.Operator, opt => opt.Ignore())
                .MapChildren<PurchaseRequisitionUpdateDto, PurchaseRequisition, PurchaseRequisitionLineCreateOrUpdateDto, PurchaseRequisitionLine>();

            CreateMap<PurchaseRequisitionLine, PurchaseRequisitionLineDto>().MapExtraProperties().ReverseMap();
            CreateMap<PurchaseRequisitionLine, PurchaseRequisitionLineCreateOrUpdateDto>().MapExtraProperties().ReverseMap();
        }
    }
} 